<!DOCTYPE html>
<html>
<head>
    <title>数据库调试</title>
    <style>
        body { font-family: Arial, sans-serif; margin: 20px; }
        h1, h2 { color: #333; }
        table { border-collapse: collapse; width: 100%; margin-bottom: 20px; }
        th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
        th { background-color: #f2f2f2; }
        tr:nth-child(even) { background-color: #f9f9f9; }
    </style>
</head>
<body>
    <h1>数据库调试信息</h1>
    
    <h2>表记录数</h2>
    <table>
        <tr>
            <th>表名</th>
            <th>记录数</th>
        </tr>
        {% for table, count in results.items() %}
            {% if not table.endswith('_sample') and not table in ['projects_query', 'users'] %}
                <tr>
                    <td>{{ table }}</td>
                    <td>{{ count }}</td>
                </tr>
            {% endif %}
        {% endfor %}
    </table>
    
    <h2>项目查询结果</h2>
    {% if results.projects_query %}
        <table>
            <tr>
                <th>ID</th>
                <th>名称</th>
                <th>代码</th>
                <th>分类</th>
                <th>状态</th>
                <th>创建者</th>
            </tr>
            {% for project in results.projects_query %}
                <tr>
                    <td>{{ project.id }}</td>
                    <td>{{ project.name }}</td>
                    <td>{{ project.code }}</td>
                    <td>{{ project.category_name }}</td>
                    <td>{{ project.status_name }}</td>
                    <td>{{ project.creator }}</td>
                </tr>
            {% endfor %}
        </table>
    {% else %}
        <p>没有查询到项目数据</p>
    {% endif %}
    
    <h2>用户数据</h2>
    {% if results.users %}
        <table>
            <tr>
                <th>ID</th>
                <th>用户名</th>
                <th>真实姓名</th>
                <th>状态</th>
            </tr>
            {% for user in results.users %}
                <tr>
                    <td>{{ user.id }}</td>
                    <td>{{ user.username }}</td>
                    <td>{{ user.real_name }}</td>
                    <td>{{ user.status }}</td>
                </tr>
            {% endfor %}
        </table>
    {% else %}
        <p>没有查询到用户数据</p>
    {% endif %}
    
    <!-- 显示每个表的示例数据 -->
    {% for table, data in results.items() %}
        {% if table.endswith('_sample') and data %}
            <h2>{{ table[:-7] }} 示例数据</h2>
            <table>
                <tr>
                    {% for column in data[0].keys() %}
                        <th>{{ column }}</th>
                    {% endfor %}
                </tr>
                {% for row in data %}
                    <tr>
                        {% for value in row.values() %}
                            <td>{{ value }}</td>
                        {% endfor %}
                    </tr>
                {% endfor %}
            </table>
        {% endif %}
    {% endfor %}
</body>
</html> 